package com.bdqn.qnnews.tess4j.config;

import lombok.Data;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xlzhang
 */
@Data
@Configuration
@ConditionalOnClass(Tesseract.class)
@EnableConfigurationProperties(QnTess4jProperties.class)
public class Tess4JAutoConfiguration {


    @Bean
    public ITesseract iTesseract(QnTess4jProperties prop){
        ITesseract tesseract = new Tesseract();
        // 设置语言包
        tesseract.setDatapath(prop.getDatapath());
        // 设置语音包名称
        tesseract.setLanguage(prop.getLanguage());
        return tesseract;
    }
}